package src.lab03.test11;

import java.beans.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
 * Created by 12442 on 2017/12/20.
 */
public class Test {
    public static void main(String[] args) {

        //3+1
        Connection connection = null;
        java.sql.Statement statement = null;
        ResultSet resultSet = null;

        String sql = "insert into"+" t_users(id,username,password,register_datetime)"+" values(1,'admin','admin',192312312123";
        String sql1 = "insert into"+" t_users(id,username,password,register_datetime)"+" values(2,'chen','123456',12312312123";
        try {
            Class.forName("com.mysql.jdbc.Driver");

            connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/java_2017?serverTimezone=UTC",
                    "root",
                    "123456");
            statement = connection.createStatement();

            statement.execute(sql);
            statement.execute(sql1);


        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        finally {
            try {
                connection.close();
                resultSet.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
